/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * watchVideosOnline.java
 *
 * Created on Jun 19, 2010, 4:01:11 PM
 */

package jvid;

import java.io.BufferedReader;
import java.io.PrintWriter;
import java.net.Socket;

/**
 *
 * @author david
 */
public class watchVideosOnline extends javax.swing.JDialog {

    /** Creates new form watchVideosOnline */
    public watchVideosOnline(Socket so,PrintWriter out,BufferedReader in) {
        initComponents();
        videoTrans = so;
        outX = out;
        inX  = in;
        feedback.setText("Actualmente conectado a: "+videoTrans.getInetAddress().getHostAddress()+" en el puerto: "+videoTrans.getPort());
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel3 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jLabel1 = new javax.swing.JLabel();
        feedback = new javax.swing.JLabel();
        desconectar = new javax.swing.JButton();
        verVideo = new javax.swing.JButton();

        jLabel3.setText("jLabel3");

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Elige un video de la lista");

        jLabel1.setAutoscrolls(true);
        jLabel1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jScrollPane1.setViewportView(jLabel1);

        feedback.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N
        feedback.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        feedback.setText(" ");

        desconectar.setText("Desconectar");
        desconectar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                desconectarActionPerformed(evt);
            }
        });

        verVideo.setText("Ver video");
        verVideo.setEnabled(false);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .add(20, 20, 20)
                .add(feedback, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 404, Short.MAX_VALUE)
                .addContainerGap())
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(layout.createSequentialGroup()
                        .add(verVideo)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(desconectar))
                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .add(22, 22, 22)
                .add(feedback, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 13, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(18, 18, 18)
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 323, Short.MAX_VALUE)
                .add(18, 18, 18)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(desconectar)
                    .add(verVideo))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void desconectarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_desconectarActionPerformed
        try {
            videoTrans.close();
            outX = null;
            inX = null;
            this.dispose();
            feedback.setText("Desconexion realizada con exito.");
        } catch (Exception E) {
            feedback.setText("Error al intentar desconectar, reinicie el programa.");
        }
    }//GEN-LAST:event_desconectarActionPerformed

    /**
    * @param args the command line arguments
    */


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton desconectar;
    private javax.swing.JLabel feedback;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton verVideo;
    // End of variables declaration//GEN-END:variables
    public Socket videoTrans;
    public PrintWriter outX;
    public BufferedReader inX;
}
